(deftemplate s
(slot om)
(slot animal)
(slot tigari)
(slot pozitie)
)

(foreach ?om (create$ englez rus spaniol)
(foreach ?animal (create$ cal lup caine)
(foreach ?tigara (create$ Kent LM LuckyStrike)
(foreach ?p (create$ 1 2 3 )
(assert (s (om ?om)(animal ?animal)(tigari ?tigara)(pozitie ?p)))
)
)
)
 )



(defrule ProblemaCaselor
   (s (om ?oma) (animal ?ana & lup)(tigari ?ta & ~LuckyStrike) (pozitie ?pa) )
   (s (om ?omb & ~?oma) (animal ?anb & ~?ana)(tigari ?tb & LuckyStrike)(pozitie ?pb &: (eq ?pb (+ ?pa 1))))
   ?f1<-(s (om ?o1 & englez)(animal ?a1)(tigari ?t1)(pozitie ?p1 & 1))
   (test (or (neq ?a1 lup)(neq ?t1 LuckyStrike)))
   ?f2<-(s  (om ?o2 & rus & ~?o1 & ~?oma) (animal ?a2 & cal & ~?a1 & ~?ana)(tigari ?t2 & ~?t1 & ~?ta)(pozitie ?p2 & ~?p1 & ~?pa))
   ?f3<-(s (om ?o3 & spaniol & ~?o1 & ~?o2 & ?omb) (animal ?a3 & ~?a2 & ~?a1 & ~?anb)(tigari ?t3 & Kent & ~?t2 & ~?t1 & ~?tb)(pozitie ?p3 & ~?p2 & ~?p1 & ~?pb))
   (test (or (neq ?a3 lup)(neq ?p3 3)))
    =>
    (printout t crlf "***************Solutie*********" crlf)
    (printout t "Persoana " ?o1 " Animal " ?a1 " Tigari " ?t1 " Pozitie " ?p1 crlf)
    (printout t "Persoana " ?o2 " Animal " ?a2 " Tigari " ?t2 " Pozitie " ?p2 crlf)
    (printout t "Persoana " ?o3 " Animal " ?a3 " Tigari " ?t3 " Pozitie " ?p3 crlf)
    (retract ?f1)
    (retract ?f2)
    (retract ?f3)
    
)

(run)